package com.sky.controller.user;

import com.sky.constant.RedisKeyConStant;
import com.sky.constant.StatusConstant;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/shop")
@Slf4j
@Api(tags = "客户端店铺操作接口")
public class FrontShopController {

    @Autowired
    private RedisTemplate redisTemplate;

    @ApiOperation("修改店铺状态")
    @GetMapping("/status")
    public Result FrontGetShopStatus(){
        Integer status = (Integer) redisTemplate.opsForValue().get(RedisKeyConStant.SHOP_STATUS_KEY);
        if (status == null){
            redisTemplate.opsForValue().set(RedisKeyConStant.SHOP_STATUS_KEY, StatusConstant.SHOP_DISABLE);
            return Result.success(status);
        }
        return Result.success(status);
    }
}
